<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>我的游戏</title>
		<style>
			#waiceng {
				width: 1280px;
				height: 720px;
				margin: 0 auto;
				position: relative;
				border: 1px solid #000000;
				/* margin: 680px 400px 0;width: 160px;height: 90px; */
			}
			#canvas {
				z-index: 0;
				position: absolute;
				width: 100%;
				height: 100%;
				opacity: 1;
			}
			#jiemian {
				z-index: 1;
				position: absolute;
				width: 100%;
				height: 100%;
				opacity: 1;
			}
			span {
				user-select:none;
			}
		</style>
	</head>
	<body>
		<div id="waiceng">
			<canvas id="canvas" width="1280px" height="720px"></canvas>
			<canvas id="jiemian" width="1280px" height="720px"></canvas>
		</div>
		<!-- <span>走近npc范围：互动 esc：退出副本 x：普攻 b：背包 方向键：移动 右键：买卖丢弃物品 双击：使用物品 </span> -->
		<script>
			var canvas = document.getElementById('canvas');
			var jiemian = document.getElementById('jiemian');
			var ctx = canvas.getContext('2d');
			var ctxjm = jiemian.getContext('2d');
			var huajihe = [];
			var guaijihe = [];
			var taceng = 0;
			var xinxixianshi = false;
			var zongshangdian;
			var shangdianxianshi = false;
			var ex = 0,ey = 0;
			
			jiemian.onmousemove = function (e) {
				if (xinxixianshi) {
					ex = e.offsetX;
					ey = e.offsetY;
				}
				if (shangdianxianshi) {
					ex = e.offsetX;
					ey = e.offsetY;
				}
			}
			//使用物品
			jiemian.ondblclick = function (e) {				
				e.preventDefault();
				let a = shubiaobao(e.offsetX,e.offsetY);
				if (a!=undefined) {
					if (xinxixianshi) {
						let q = nwo.baoguo[a]
						if (q) {
							if (q.name == '回血药剂') {
								nwo.xueliang = nwo.zongxueliang;
								nwo.baoguo.splice(a,1);
							}
						}
					}
				}
			}
			jiemian.onmousedown = function (e) {
				let a = shubiaobao(e.offsetX,e.offsetY);
				let b = shushangdian(e.offsetX,e.offsetY);
				if (e.button == 2) {
					//卖丢弃
					if (a!=undefined) {
						if (xinxixianshi) {
							if (shangdianxianshi) {
								if (nwo.baoguo[a]&&nwo.baoguo[a].zhenpin) {
									if (confirm('卖珍品？')) {
										let q = nwo.baoguo.splice(a,1)[0]
										q?nwo.qian += q.jiage:false;
									}else return;
								}
								let q = nwo.baoguo.splice(a,1)[0]
								q?nwo.qian += q.jiage:false;
							}else{
								if (nwo.baoguo[a]) {
									confirm('丢弃')?nwo.baoguo.splice(a,1):false;
								}
							}
						}
					}
					//买
					if (b!=undefined) {
						if (shangdianxianshi) {
							let q = zongshangdian.shangpin[b];
							if (q) {
								if (xinxixianshi == false) {
									xinxixianshi = true;
									return;
								}
								if (nwo.qian - q.jiage >= 0&&nwo.baoguo.length < 72) {
									nwo.qian -= q.jiage;
									nwo.baoguo.push(q);
								}
							}
						}
					}
				}
			}
			window.oncontextmenu = function (e) {
				e.preventDefault();
			}
			window.onkeydown = function (e) {
				//长按 时差不等
				if (e.key == 'ArrowRight') {			
					nwo.fangxiangy = 'y';
					nwo.fangxiangz = '';
					nwo.chaoxiang = 'y';
				}
				if (e.key == 'ArrowLeft') {
					nwo.fangxiangz = 'z';
					nwo.fangxiangy = '';
					nwo.chaoxiang = 'z';
				}
				if (e.key == 'ArrowUp') {
					nwo.fangxiangs = 's';
					nwo.fangxiangx = '';
				}
				if (e.key == 'ArrowDown') {
					nwo.fangxiangx = 'x';
					nwo.fangxiangs = '';
				}
				if (e.key == 'x') {						
					if (nwo.gjsuo) {
						(new Date() - nwo.shijian < 1500)?nwo.ptgjsuo = !nwo.ptgjsuo :nwo.ptgjsuo = true;						
						nwo.ptgongji();
					}
				}
				if (e.key == 'q') {
					nwo.xiaofeijian()
				}
				if (e.key == 'w') {
					nwo.dafeijian()
				}
				if (e.key == 'b') {
					xinxixianshi = !xinxixianshi;
					ex = 0,ey = 0;
				}
				if (e.key == 'Escape') {
					if (ditu == 'tuta') {
						nwo = new wo();
						jihepeizhi();
					}
				}
			}
			window.onkeyup = function (e) {
				if (e.key == 'ArrowRight') {
					nwo.fangxiangy = ''
				}
				if (e.key == 'ArrowLeft') {
					nwo.fangxiangz = ''
				}
				if (e.key == 'ArrowUp') {
					nwo.fangxiangs = ''
				}
				if (e.key == 'ArrowDown') {
					nwo.fangxiangx = ''
				}
			}
			
			//存档
			function cundangh() {
				let cundangzuobiao = {x:nwo.x,y:nwo.y,}
				let cundang = {					
					gongjili:nwo.gongjili,
					xueliang:nwo.xueliang,
					zongxueliang:nwo.zongxueliang,
					baoguo:nwo.baoguo,
					qian:nwo.qian
				}
				if (ditu == 'tu') {
					localStorage.setItem('cundangzuobiao',JSON.stringify(cundangzuobiao))
				}
				localStorage.setItem('cundang',JSON.stringify(cundang))
			}
			//读档
			function dudangh(a) {
				if (localStorage.getItem('cundang')) {
					if (localStorage.getItem('cundangzuobiao')) {
						if (a=='x'||a=='y') {
							return JSON.parse(localStorage.getItem('cundangzuobiao'))[a]
						}
					}
					if (a == 'xueliang'&&JSON.parse(localStorage.getItem('cundang'))[a]===0) {
						return 10;
					}
					return JSON.parse(localStorage.getItem('cundang'))[a]
				}
			}
			function shengyin() {
				if (!nwo.huozhe) return;	
				// 创建音频上下文
				var audioCtx = new AudioContext();
				// 创建音调控制对象  
				var oscillator = audioCtx.createOscillator();
				// 创建音量控制对象  
				var gainNode = audioCtx.createGain();
				// 音调音量关联  
				oscillator.connect(gainNode);
				// 音量和设备关联  
				gainNode.connect(audioCtx.destination);
				// 音调类型
				oscillator.type = 'triangle';
				// 设置音调频率  
				oscillator.frequency.value = 30.00;
				// 先把当前音量设为0  
				gainNode.gain.setValueAtTime(0, audioCtx.currentTime);
				// 0.01秒时间内音量从刚刚的0变成1，线性变化 
				gainNode.gain.linearRampToValueAtTime(2, audioCtx.currentTime + 0.01);
				// 声音走起 
				oscillator.start(audioCtx.currentTime);
				// 1秒时间内音量从刚刚的1变成0.001，指数变化 
				gainNode.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.5);
				// 1秒后停止声音 
				oscillator.stop(audioCtx.currentTime + 0.5);
				setTimeout(()=> audioCtx.close(),1500)
			}
			//怪血量攻击提升
			function guaitisheng(a) {				
				for (let i=1;i<taceng;i++) {
					a *= 1.2
				}
				return a
			}
			//鼠标选中背包
			function shubiaobao(x,y) {
				let a = -1;
				for (let r=0;r<12;r++) {
					for (let c=0;c<6;c++) {
						a++;
						if ((x>900+40*c&&x<900+40*c+40)&&(y>110+40*r&&y<110+40*r+40)) {							
							return a
						}
					}
				}
			}
			//鼠标选中商店
			function shushangdian(x,y) {
				let a = -1;
				for (let r=0;r<8;r++) {
					for (let c=0;c<8;c++) {
						a++;
						if ((x>160+40*c&&x<160+40*c+40)&&(y>180+40*r&&y<180+40*r+40)) {							
							return a
						}
					}
				}
			}
			//界面
			function jiemianh() {
				ctxjm.clearRect(0,0,canvas.width,canvas.height)
				//血条				
				ctxjm.save()
				ctxjm.beginPath();
				ctxjm.moveTo(40,jiemian.height-30);
				ctxjm.lineTo(340,jiemian.height-30)
				ctxjm.strokeStyle = '#70716b';
				ctxjm.lineWidth = 50;
				ctxjm.lineCap = "square";
				ctxjm.stroke()
				ctxjm.beginPath();
				ctxjm.moveTo(40,jiemian.height-30);
				ctxjm.lineTo(40+nwo.xueliang*nwo.zongxuetiao/nwo.zongxueliang,jiemian.height-30)
				ctxjm.strokeStyle = '#d5474e';
				ctxjm.lineWidth = 40;
				ctxjm.lineCap = "butt";
				ctxjm.stroke()
				ctxjm.beginPath();
				ctxjm.fillStyle = '#ffffff';
				ctxjm.textAlign = 'center';
				ctxjm.font = '30px 楷体';
				ctxjm.fillText(`${Math.round(nwo.xueliang)}/${Math.round(nwo.zongxueliang)}`,200,jiemian.height-20)
				ctxjm.restore()
				//小飞剑图标
				ctxjm.save()
				ctxjm.fillStyle = '#dddddd'
				ctxjm.strokeStyle = '#2e5051'
				ctxjm.rect(500,660,50,50)
				ctxjm.fill()
				ctxjm.stroke()
				let fjy = new Path2D(`M540 680 l-8 -3 h-15 v2 h-6 v2 h6 v2 h15 z`)
				ctxjm.fillStyle = '#89eaef'
				ctxjm.strokeStyle = '#4b8284'
				ctxjm.fill(fjy)
				ctxjm.fillStyle = '#120501'
				ctxjm.font = '20px 楷体';
				ctxjm.fillText(`Q`,535,705)
				ctxjm.stroke(fjy)
				//冷却文字
				if (nwo.xfjcd<2000&&nwo.xfjcd>0) {
					ctxjm.fillStyle = '#acacac'
					ctxjm.globalAlpha = 0.5;
					ctxjm.fillRect(500,660,50,50)
					ctxjm.globalAlpha = 1;
					ctxjm.fillStyle = '#ff5410'
					ctxjm.font = '32px 楷体';
					ctxjm.fillText(`${Math.floor(nwo.xfjcd/1000*10)/10}`,500,690)
				}
				ctxjm.restore()
				//大飞剑图标
				ctxjm.beginPath()
				ctxjm.save()
				ctxjm.fillStyle = '#dddddd'
				ctxjm.strokeStyle = '#2e5051'
				ctxjm.rect(560,660,50,50)
				ctxjm.fill()
				ctxjm.stroke()
				let fjd = new Path2D(`M610 680 l-10 -5 h-30 v3 h-8 v4 h8 v3 h30 z`)
				ctxjm.fillStyle = '#4d96ef'
				ctxjm.strokeStyle = '#83e4e7'
				ctxjm.fill(fjd)
				ctxjm.fillStyle = '#120501'
				ctxjm.font = '20px 楷体';
				ctxjm.fillText(`w`,595,705)
				ctxjm.stroke(fjd)
				if (nwo.fjzt != 5) {
					ctxjm.save();
					ctxjm.fillStyle = '#acacac'
					ctxjm.globalAlpha = 0.5;
					ctxjm.fillRect(560,660,50,50)
					ctxjm.restore()
				}
				ctxjm.restore()
				//显示人物信息
				if (xinxixianshi) {
					ctxjm.save()
					ctxjm.fillStyle = '#8fb2d1'
					ctxjm.strokeStyle = '#2f404c'
					ctxjm.lineWidth = 5;
					ctxjm.fillRect(700,100,450,500)
					ctxjm.strokeRect(700,100,450,500)
					ctxjm.fillStyle = '#efefef';
					ctxjm.font = '17px 楷体';
					ctxjm.fillText(`攻击力:${Math.round(nwo.gongjili)}`,705,130);
					ctxjm.fillStyle = '#f1ec47';
					ctxjm.fillText(`钱:${Math.round(nwo.qian)}`,750,590);
					//画包裹
					ctxjm.fillStyle = '#cee8fc'
					ctxjm.strokeStyle = '#d0d0d0'
					let a = -1;
					for (let r=0;r<12;r++) {
						for (let c=0;c<6;c++) {							
							ctxjm.fillRect(900+40*c,110+40*r,40,40)
							ctxjm.strokeRect(900+40*c,110+40*r,40,40)
							ctxjm.save()
							ctxjm.fillStyle = '#505a62'
							ctxjm.font = '20px 楷体';
							a++;
							nwo.baoguo[a]?ctxjm.fillText(`${nwo.baoguo[a].name}`,900+40*c,110+40*r+25):false;
							ctxjm.restore()
						}
					}
					ctxjm.restore()
					if (nwo.baoguo[shubiaobao(ex,ey)]) {
						ctxjm.save()
						ctxjm.strokeStyle = '#8c9eab';
						ctxjm.fillStyle = '#c6dff1';
						ctxjm.lineWidth = 4;
						ctxjm.strokeRect(700,10,450,80)
						ctxjm.fillRect(700,10,450,80)
						ctxjm.fillStyle = '#363d42'
						ctxjm.font = '20px 楷体';
						ctxjm.fillText(`名称：${nwo.baoguo[shubiaobao(ex,ey)].name}`,850,30)
						ctxjm.fillText(`类型：${nwo.baoguo[shubiaobao(ex,ey)].leixing}`,700,55)
						ctxjm.fillText(`${nwo.baoguo[shubiaobao(ex,ey)].zhenpin?'珍品':''}`,850,55)
						ctxjm.fillText(`价格：${nwo.baoguo[shubiaobao(ex,ey)].jiage}`,1000,85)
						ctxjm.restore()
					}
				}
				//画商店
				if (shangdianxianshi) {
					ctxjm.save()
					ctxjm.fillStyle = '#a8d1ca'
					ctxjm.strokeStyle = '#2f404c'
					ctxjm.lineWidth = 5;
					ctxjm.fillRect(100,100,450,500)
					ctxjm.strokeRect(100,100,450,500)
					ctxjm.fillStyle = '#efefef';
					ctxjm.font = '30px 楷体';
					ctxjm.fillText(`商店`,290,150);
					//画商品
					ctxjm.fillStyle = '#cee8fc'
					ctxjm.strokeStyle = '#d0d0d0'
					let a = -1;
					for (let r=0;r<8;r++) {
						for (let c=0;c<8;c++) {							
							ctxjm.fillRect(160+40*c,180+40*r,40,40)
							ctxjm.strokeRect(160+40*c,180+40*r,40,40)
							ctxjm.save()
							ctxjm.fillStyle = '#505a62'
							ctxjm.font = '20px 楷体';
							a++;
							zongshangdian.shangpin[a]?ctxjm.fillText(`${zongshangdian.shangpin[a].name}`,160+40*c,180+40*r+25):false;
							ctxjm.restore()
						}
					}
					ctxjm.restore()
					if (zongshangdian.shangpin[shushangdian(ex,ey)]) {
						ctxjm.save()
						ctxjm.strokeStyle = '#8c9eab';
						ctxjm.fillStyle = '#c6dff1';
						ctxjm.lineWidth = 4;
						ctxjm.strokeRect(100,10,450,80)
						ctxjm.fillRect(100,10,450,80)
						ctxjm.fillStyle = '#363d42'
						ctxjm.font = '20px 楷体';
						ctxjm.fillText(`名称：${zongshangdian.shangpin[shushangdian(ex,ey)].name}`,240,30)
						ctxjm.fillText(`类型：${zongshangdian.shangpin[shushangdian(ex,ey)].leixing}`,100,55)
						ctxjm.fillText(`${zongshangdian.shangpin[shushangdian(ex,ey)].zhenpin?'珍品':''}`,240,55)
						ctxjm.fillText(`价格：${zongshangdian.shangpin[shushangdian(ex,ey)].jiage}`,400,85)
						ctxjm.restore()
					}
				}
			}
			//人物
			class wo {
				constructor() {
					this.huabu = document.createElement('canvas');
					this.leixing = 'renwu';
					this.huozhe = true;
				    this.x = dudangh('x')||75;
					this.y = dudangh('y')||475;
					this.baoguo = dudangh('baoguo')||[];
					this.qian = dudangh('qian')||0;
					this.chaoxiang = 'y';
					this.fangxiangy = "";
					this.fangxiangz = "";
					this.fangxiangs = "";
					this.fangxiangx = "";
					this.zdt= 110;
					this.zxt= 5;
					this.ydt= 60;
					this.yxt= 20;
					this.ydbj= 140;
					this.yxbj= 320;
					this.yxbc= 26;
					this.wqj= 280;
					this.wqsf= 1;
					this.wqsf1= 1;
					this.suo = true;
					this.ptgjsuo= true;
					this.gjsuo= true;
					this.shijian = null;
					this.pengdao = false;
					this.gongjili = dudangh('gongjili')||10;
					this.zongxueliang = dudangh('zongxueliang')||50;
					this.zongxuetiao = 300;
					this.xueliang = dudangh('xueliang')||50;
					this.xfjsuo = false;
					this.xfjcd = 2000;
					this.xfjfx = 'y';
					this.xfjx = 0;
					this.xfjy = 0;
					this.fjzt = 0;
					this.dfjsuo = false;
					this.dfjfx = 'y';
					this.dfjx = 0;
					this.dfjy = 0;
					this.donghuazhen();
				}
				//位置
				tiding() {
					return this.y-20;
				}
				tidi() {
					return this.y+160;
				}
				tidinei() {
					return this.y+120;
				}
				tizuo() {
					return this.x-40;
				}
				tiyou() {
					return this.x+40;
				}
				tiqian() {
					if (this.chaoxiang == 'y') return this.tiyou();
					if (this.chaoxiang == 'z') return this.tizuo();
				}
				tihou() {
					if (this.chaoxiang == 'y') return this.tizuo();
					if (this.chaoxiang == 'z') return this.tiyou();
				}
				wqqian() {
					if (this.chaoxiang == 'y') return this.tiqian()+110;
					if (this.chaoxiang == 'z') return this.tizuo()-110;
				}
				wqhou() {
					if (this.chaoxiang == 'y') return this.tiqian()-10;;
					if (this.chaoxiang == 'z') return this.tizuo()+10;
				}
				beigongji(a) {
					let s = this;
					if (s.xueliang>0) {
						s.xueliang -= a;
						s.xueliang<0?s.xueliang=0:true;
					}
					if (s.xueliang==0) {
						s.huozhe = false;
					}
				}
				//动画帧
				donghuazhen() {
					// this.huabu.width = canvas.width;
					// this.huabu.height = canvas.height;
					// let ctx =  this.huabu.getContext('2d');
					// ctx.fillStyle = '#ffffff'
					// ctx.fillRect(0,0,canvas.width,canvas.height);
					// let mx = 400,my = 600;
					// var a = new Path2D(`M${mx} ${my} c0 -30,-40 -10,-50 0`)
					// ctx.lineWidth = 1;
					// ctx.strokeStyle = '#a2a2a2'
					// ctx.stroke(a);
					// var a = new Path2D(`M${mx-20} ${my-15} a10 11 0 1 0 10 0`)
					// ctx.strokeStyle = '#a2a2a2'
					// ctx.stroke(a);
					// ctx.fillStyle = '#969696'
					// ctx.fill(a);
					// var a = new Path2D(`M${mx-14} ${my-12} a4 5 0 1 0 1 0`)
					// ctx.fillStyle = '#5f5f5f'
					// ctx.fill(a);
					// var a = new Path2D(`M${mx-19} ${my-10} a3 2 0 1 0 1 0`)
					// ctx.fillStyle = '#e5e5e5'
					// ctx.fill(a);
					// var a1 = new Path2D(`M${mx+55} ${my} c0 -30 -20 -10 -30 0`)
					// ctx.strokeStyle = '#a2a2a2'
					// ctx.stroke(a1);
					// var a1 = new Path2D(`M${mx+42} ${my-15} a8 10 0 1 0 8 0`)
					// ctx.strokeStyle = '#a2a2a2'
					// ctx.stroke(a1);
					// ctx.fillStyle = '#969696'
					// ctx.fill(a1);
					// var a1 = new Path2D(`M${mx+47} ${my-12} a4 5 0 1 0 1 0`)
					// ctx.fillStyle = '#5f5f5f'
					// ctx.fill(a1);
					// var a1 = new Path2D(`M${mx+43} ${my-10} a2 2 0 1 0 1 0`)
					// ctx.fillStyle = '#e5e5e5'
					// ctx.fill(a1);
					// var a1 = new Path2D(`M${mx+40} ${my-20} c-10,-20 -30,20 -16,15 z`)
					// ctx.fillStyle = '#cacaca'
					// ctx.fill(a1);
					
				}
				//移动判定
				yidongpanding() {
					let pengdao;
					let s = this;
					let dianzu = [
						[s.tiqian(),s.tidi()],
						[s.tihou(),s.tidi()],
						[s.tiqian(),s.tidinei()],
						[s.tihou(),s.tidinei()],
						[s.tiqian(),(s.tidi()+s.tidinei())/2],
						[s.tihou(),(s.tidi()+s.tidinei())/2]
					]
					//碰撞
					if (s.tizuo()<=30||s.tiyou()>=canvas.width-10||s.tiding()<=150||s.tidi()>=canvas.height) {
						pengdao = true;
					}
					huajihe.forEach(i=>{
						dianzu.forEach(x=>{
							if (i.leixing != 'renwu') {
								if (i.leixing == 'men') {
									if (!i.jinru) {
										if (x[0] >= i.tizuo()&& x[0] <= i.tiyou()&&x[1] <= i.tidi()&&x[1] >= i.tidinei()) pengdao = true;
									}
								}
								if (i.leixing == 'guai') {
									if (i.huozhe){
										if (x[0] >= i.tizuo()&& x[0] <= i.tiyou()&&x[1] <= i.tidi()&&x[1] >= i.tidinei()) pengdao = true;
									}
									//拾取
									if (nwo.baoguo.length < 72) {
										if (!i.huozhe) {
											if (i.shiqu&&(x[0] >= i.tizuo()&& x[0] <= i.tiyou()&&x[1] <= i.tidi()&&x[1] >= i.tidinei())) {
												i.shiqu = false;
												if (i.bianhao.includes('slm')) {
													s.baoguo.push({name:'史莱姆骨头',zhenpin:false,leixing:'杂物',jiage:1})
												}
											}
										}
									}
								}
								if (i.leixing == 'shangdian') {
									if (x[0] >= i.tizuo()&& x[0] <= i.tiyou()&&x[1] <= i.tidi()&&x[1] >= i.tidinei()) shangdianxianshi = true;
									else shangdianxianshi = false;
								}
							}
						})
					})
					return pengdao
				}
				//移动函数
				ydh() {
					var m = 3 ;
					var s = this;
					var yidong = function () {
						let a = 0;
						var yds = [
							[110,5,60,20],
							[105,6.5,65,18.5],
							[100,8,70,17],
							[95,9.5,75,15.5],
							[90,11,80,14],
							[85,12.5,85,12.5],
							[80,14,90,11],
							[75,15.5,95,9.5],
							[70,17,100,8],
							[65,18.5,105,6.5],
							[60,20,110,5]
						]
						var ff = function () {
							s.zdt= yds[a][0];
							s.zxt= yds[a][1];
							s.ydt= yds[a][2];
							s.yxt= yds[a][3];
							a++;
						}
						if (s.suo) {
							s.suo = false;
							let si = setInterval(function () {
								ff(a);
								if (a==10) { 
									s.zdt = 110;
									s.zxt = 5;
									s.ydt = 60;
									s.yxt = 20;
									clearInterval(si);
									s.suo = true;
								}
							},1000/40)
						}
					}
					if (s.fangxiangy == 'y') {
						s.x += m;
						s.yidongpanding()?s.x -= m:true;
						yidong()
					}
					if (s.fangxiangz == 'z') {
						s.x -= m;
						s.yidongpanding()?s.x += m:true;
						yidong()
					}					
					if (s.fangxiangs == 's') {
						s.y -= m;
						s.yidongpanding()?s.y += m:true;
						yidong()
					}					
					if (s.fangxiangx == 'x') {
						s.y += m;
						s.yidongpanding()?s.y -= m:true;
						yidong()
					}
				}
				gongjidonghua() {
					let s = this;
					s.ydbj= 0;
					s.yxbj= 280;
					s.yxbc= 26;
					s.wqj= 280;
					s.wqsf= 1;
					let si = setInterval(function () {							
						s.ydbj += (140-0)/10;
						s.yxbj += (320-280)/10;
						if (s.ydbj > 140) { 
							clearInterval(si);
							setTimeout(()=>{
								s.ydbj= 140;
								s.yxbj= 320;
								s.yxbc= 26;
								s.wqj= 280;
								s.wqsf= 1;
								s.wqsf1= 1;
							},300)
						}						
					},1000/60)
				}
				ptgongji() {
					var s= this;						
					var pgs = [
							[46,240,9,320,0.2,0.5],
							[46,260,14,340,0.4,0.3],
							[46,270,18,350,0.5,0.2],
							[46,280,22,360,0.6,0.1],
							[46,290,24,0,0.7,0.1],
							[46,300,26,0,0.8,0.1],
							[46,310,12,0,1,0.1],
							[60,330,12,0,0.8,0.1],
							[80,350,11,0,0.6,0.2],
							[100,350,10,0,0.4,0.3],
							[120,350,10,0,0.4,0.5],
							[130,350,10,0,0.5,0.7],
							[140,350,10,0,0.5,0.8],
						]
					let f = function () {
						s.ydbj= pgs[a][0];
						s.yxbj= pgs[a][1];
						s.yxbc= pgs[a][2];
						s.wqj= pgs[a][3];
						s.wqsf= pgs[a][4];
						s.wqsf1= pgs[a][5];
						a++;
					}
					if (s.gjsuo&&s.ptgjsuo) {	
						var a = 0;
						s.gjsuo = false;
						let si = setInterval(function () {
							f();
							if (a == 12) {
								clearInterval(si);								
								setTimeout(()=>{									
									s.ydbj= 140;
									s.yxbj= 320;
									s.yxbc= 26;
									s.wqj= 280;
									s.wqsf= 1;
									s.wqsf1= 1;
									s.gjsuo = true;
									s.shijian = new Date();
								},300)
							}							
						},1000/60)
					}
					if (s.gjsuo&&!s.ptgjsuo) {
						s.ydbj= 0;
						s.yxbj= 280;
						s.yxbc= 26;
						s.wqj= 280;
						s.wqsf= 1;
						s.gjsuo = false;
						let si = setInterval(function () {							
							s.ydbj += (140-0)/10;
							s.yxbj += (320-280)/10;
							if (s.ydbj > 140) { 
								clearInterval(si);
								setTimeout(()=>{
									s.ydbj= 140;
									s.yxbj= 320;
									s.yxbc= 26;
									s.wqj= 280;
									s.wqsf= 1;
									s.wqsf1= 1;
									s.gjsuo = true;
									s.shijian = new Date();
								},300)
							}						
						},1000/60)
					}
					//普攻判定
					let gjpanding = function () {
						huajihe.forEach(x=>{
							if (x.leixing != 'renwu') {
								if ((s.tidi() < x.tidi()&&s.tidi() > x.tidinei())||
								(s.tidinei() < x.tidi()&&s.tidinei() > x.tidinei())
								) {
									if ((s.wqqian() > x.tizuo() && s.wqhou() < x.tizuo())||
									(s.wqqian() < x.tiyou() && s.wqhou() > x.tiyou())) {
										x.beigongji(s.gongjili);
									}
								}
							}
						})
					}
					gjpanding()
				}
				//小飞剑
				xiaofeijian() {
					var s= this;					
					if (s.xfjcd == 2000) {
						s.gongjidonghua();
						let cd = setInterval(function () {
							s.xfjcd -= 1000/60;
							if (s.xfjcd < 0) {
								s.xfjcd = 2000;
								clearInterval(cd)
							}
						},1000/60)
						let a;
						let xfjhou;
						s.xfjsuo = true;
						s.xfjfx = s.chaoxiang;						
						if (s.xfjfx == 'y') {
							s.xfjx = s.x+80;
							s.xfjy = s.y+50;
							xfjhou = s.xfjx - 60;
							a = s.x+80;
						}
						if (s.xfjfx == 'z') {
							s.xfjx = s.x-80;
							s.xfjy = s.y+50;
							xfjhou = s.xfjx + 60;
							a = s.x-80;
						}	
						let f = function () {
							if (s.xfjfx == 'y') {
								s.xfjx += 10;
								xfjhou += 10;
							}
							if (s.xfjfx == 'z') {
								s.xfjx -= 10;
								xfjhou -= 10;
							}								
						}
						//击中判定
						let panding = function () {
							for (let x of huajihe) {
								if (x.leixing != 'renwu') {
									if (((s.xfjx <= x.tiyou()&&s.xfjx >= x.tizuo())||
									(xfjhou <= x.tiyou()&&xfjhou >= x.tizuo()))&&
									s.xfjy <= x.tidi()&&s.xfjy >= x.tiding()&&x.huozhe) {
										if (x.leixing == 'guai') {
											x.beigongji(s.gongjili);
											if (s.fjzt < 5) s.fjzt++;
										}										
										clearInterval(si);
										s.xfjsuo = false;
										break;
									}
								}
							}
						}
						//移动计算
						let si = setInterval(function () {
							f();
							panding();
							if (Math.abs(s.xfjx-a) > canvas.width/5*4) {
								clearInterval(si);
								s.xfjsuo = false;
							}							
						},1000/60)
					}					
				}
				//大飞剑
				dafeijian() {
					var s= this;					
					if (s.fjzt == 5) {
						s.fjzt = 0;
						s.gongjidonghua();
						let a;
						let dfjhou;
						s.dfjsuo = true;
						s.dfjfx = s.chaoxiang;						
						if (s.dfjfx == 'y') {
							s.dfjx = s.x+130;
							s.dfjy = s.y+50;
							dfjhou = s.dfjx - 110;
							a = s.x+130;
						}
						if (s.dfjfx == 'z') {
							s.dfjx = s.x-130;
							s.dfjy = s.y+50;
							dfjhou = s.dfjx + 110;
							a = s.x-130;
						}	
						let f = function () {
							if (s.dfjfx == 'y') {
								s.dfjx += 10;
								dfjhou += 10;
							}
							if (s.dfjfx == 'z') {
								s.dfjx -= 10;
								dfjhou -= 10;
							}								
						}
						//击中判定
						let panding = function () {
							for (let x of huajihe) {
								if (x.leixing != 'renwu') {
									if (((s.dfjx <= x.tiyou()&&s.dfjx >= x.tizuo())||
									(dfjhou <= x.tiyou()&&dfjhou >= x.tizuo()))&&
									s.dfjy <= x.tidi()&&s.dfjy >= x.tiding()&&x.huozhe) {
										if (x.leixing == 'guai') {
											x.beigongji(s.gongjili*5);
										}
										clearInterval(si);
										s.dfjsuo = false;
										break;
									}
								}
							}
						}
						//移动计算
						let si = setInterval(function () {
							f();
							panding();
							if (Math.abs(s.dfjx-a) > canvas.width/5*4) {
								clearInterval(si);
								s.dfjsuo = false;
							}							
						},1000/60)
					}					
				}
				hua() {
					var s = this;
					//小飞剑
					if (s.xfjsuo) {
						ctx.save()
						ctx.fillStyle = '#89eaef'
						ctx.strokeStyle = '#4b8284'
						if (s.xfjfx == 'y') {
							let fjy = new Path2D(`M${s.xfjx} ${s.xfjy} l-10 -5 h-40 v3 h-10 v4 h10 v3 h40 z`)
							ctx.fill(fjy)
							ctx.stroke(fjy)
						}
						if (s.xfjfx == 'z') {
							let fjz = new Path2D(`M${s.xfjx} ${s.xfjy} l10 -5 h40 v3 h10 v4 h-10 v3 h-40 z`)
							ctx.fill(fjz)
							ctx.stroke(fjz)	
						}
						ctx.restore()
					}
					//大飞剑
					if (s.dfjsuo) {
						ctx.save()
						ctx.fillStyle = '#2571e3';
						ctx.lineWidth = 3;
						ctx.strokeStyle = '#8fc3e3';
						if (s.xfjfx == 'y') {
							let fjy = new Path2D(`M${s.dfjx} ${s.dfjy} l-30 -7 h-65 v3 h-15 v8 h15 v3 h65 z`)
							ctx.fill(fjy)
							ctx.stroke(fjy)
						}
						if (s.xfjfx == 'z') {
							let fjz = new Path2D(`M${s.dfjx} ${s.dfjy} l30 -7 h65 v3 h15 v8 h-15 v3 h-65 z`)
							ctx.fill(fjz)
							ctx.stroke(fjz)	
						}
						ctx.restore()
					}
					//头顶飞剑状态
					ctx.save()
					ctx.fillStyle = '#89eaef'
					ctx.strokeStyle = '#4b8284'
					if (s.fjzt >= 1&&s.fjzt <= 5) {
						let fjx = new Path2D(`M${s.x-20} ${s.y-50} l-2.5 5 v15 h1.5 v5 h2 v-5 h1.5 v-15 z`)
						ctx.fill(fjx)
						ctx.stroke(fjx)
					}
					if (s.fjzt >= 2&&s.fjzt <= 5) {
						let fjx = new Path2D(`M${s.x-10} ${s.y-50} l-2.5 5 v15 h1.5 v5 h2 v-5 h1.5 v-15 z`)
						ctx.fill(fjx)
						ctx.stroke(fjx)
					}
					if (s.fjzt >= 3&&s.fjzt <= 5) {
						let fjx = new Path2D(`M${s.x} ${s.y-50} l-2.5 5 v15 h1.5 v5 h2 v-5 h1.5 v-15 z`)
						ctx.fill(fjx)
						ctx.stroke(fjx)
					}
					if (s.fjzt >= 4&&s.fjzt <= 5) {
						let fjx = new Path2D(`M${s.x+10} ${s.y-50} l-2.5 5 v15 h1.5 v5 h2 v-5 h1.5 v-15 z`)
						ctx.fill(fjx)
						ctx.stroke(fjx)
					}
					if (s.fjzt == 5) {
						let fjx = new Path2D(`M${s.x+20} ${s.y-50} l-2.5 5 v15 h1.5 v5 h2 v-5 h1.5 v-15 z`)
						ctx.fill(fjx)
						ctx.stroke(fjx)
					}
					ctx.restore()
					
					var h = function (ctx,s) {
						ctx.save()
						//头
						ctx.fillStyle = '#1c3387';
						ctx.beginPath();
						ctx.arc(s.x, s.y, 20, 0, Math.PI * 2, true);
						ctx.fill();
						//眼睛
						var rectangle = new Path2D();
						rectangle.arc(s.x+10, s.y-5, 5, 0, Math.PI * 2, true);
						ctx.fillStyle = "white";
						ctx.fill(rectangle);
						//身体
						ctx.beginPath();
						ctx.strokeStyle = '#1c3387';
						ctx.lineWidth = 12;
						ctx.lineCap = "round";
						//躯干
						ctx.moveTo(s.x, s.y+10);
						ctx.lineTo(s.x-2.5, s.y+35)
						ctx.lineTo(s.x, s.y+70)
						ctx.stroke();
						//左腿
						ctx.save()
						ctx.beginPath();
						ctx.translate(s.x, s.y+70);
						ctx.rotate(Math.PI/180*s.zdt)
						ctx.moveTo(0, 0);
						ctx.lineTo(30, 0)
						ctx.translate(35, 0);
						ctx.rotate(Math.PI/180*s.zxt)
						ctx.lineTo(35, 0)
						ctx.stroke();
						ctx.restore()
						//右腿
						ctx.save()
						ctx.beginPath();
						ctx.translate(s.x, s.y+70);
						ctx.rotate(Math.PI/180*s.ydt)
						ctx.moveTo(0, 0);
						ctx.lineTo(35, 0)
						ctx.translate(35, 0);
						ctx.rotate(Math.PI/180*s.yxt)
						ctx.lineTo(35, 0)
						ctx.stroke();
						ctx.restore()
						//左臂
						ctx.beginPath();
						ctx.moveTo(s.x, s.y+25);
						ctx.lineTo(s.x+25, s.y+77)
						ctx.stroke();
						//右臂				
						ctx.save()
						ctx.beginPath();
						ctx.translate(s.x, s.y+25);
						ctx.rotate(Math.PI/180*s.ydbj)
						ctx.moveTo(0, 0);
						ctx.lineTo(30, 0)
						ctx.translate(30, 0);
						ctx.rotate(Math.PI/180*s.yxbj)
						ctx.lineJoin="round";
						ctx.lineTo(s.yxbc, 0)						
						ctx.stroke();
							//武器
							ctx.save();
							ctx.lineCap="square";
							ctx.beginPath();
							ctx.translate(s.yxbc, 0);
							ctx.rotate(Math.PI/180*s.wqj)
							ctx.moveTo(12*s.wqsf,0)
							ctx.lineTo(85*s.wqsf,0);
							ctx.lineTo(100*s.wqsf,5*s.wqsf1);
							ctx.lineTo(85*s.wqsf,10*s.wqsf1);
							ctx.lineTo(12*s.wqsf,10*s.wqsf1);
							ctx.lineTo(12*s.wqsf,8*s.wqsf1);
							ctx.lineTo(-10*s.wqsf,8*s.wqsf1);
							ctx.lineTo(-10*s.wqsf,2*s.wqsf1);
							ctx.lineTo(12*s.wqsf,2*s.wqsf1);
							ctx.fillStyle = '#4b6d8f';
							ctx.fill();
							ctx.lineWidth = 2;
							ctx.strokeStyle = '#7eccff'
							ctx.stroke();
							ctx.restore();
						ctx.beginPath();
						ctx.moveTo(s.yxbc, 0);
						ctx.lineTo((s.yxbc+2)*s.wqsf, 0);
						ctx.stroke();
						ctx.restore()
						//影子
						ctx.save()
						ctx.beginPath();
						ctx.fillStyle = '#b3b3b3'
						ctx.translate(s.x, s.y+145)
						ctx.scale(1,0.1)
						ctx.moveTo(0,0);					
						ctx.arc(0, 0, 35, 0, 2*Math.PI, true);						
						ctx.fill()
						ctx.restore()
						ctx.restore()
					}
					if (s.chaoxiang == 'y' || s.fangxiangy == 'y') {
						h(ctx,s);
					}
					if (s.chaoxiang == 'z' || s.fangxiangz == 'z') {
						ctx.save()
						ctx.translate(canvas.width,0);
						ctx.scale(-1,1);
						let ss = Object.assign({},s);
						//this.x必须是人中线
						ss.x = canvas.width-ss.x;
						h(ctx,ss);
						ctx.restore()						
					}
					ctx.drawImage(s.huabu,0,0)
				}
			}
			//怪
			class slm {
				constructor(x,y,b) {
					this.leixing = 'guai';
					this.bianhao = b;
					this.huozhe = true;
					this.x = x;
					this.y = y;
					this.tx = 0;
					this.ty = 0;
					this.tx1 = 0;
					this.ty1 = 0;
					this.cix = 0;
					this.gongjici = false;
					this.cisuo = true;
					this.suo = true;
					this.chaoxiang = 'z';
					this.fangxiangy = "";
					this.fangxiangz = "";
					this.fangxiangs = "";
					this.fangxiangx = "";
					this.zongxueliang = guaitisheng(50);
					this.zongxuetiao = 80;
					this.xueliang =guaitisheng(50);
					this.xuetiao =80;
					this.gongjili = guaitisheng(10);
					this.wenben = [];
					this.shiqu = false;
				}
				//位置
				tiding() {
					return this.y-100
				}
				tidi() {
					return this.y+30;
				}
				tidinei() {
					return this.y-20;
				}
				tizuo() {
					return this.x-70;
				}
				tiyou() {
					return this.x+70;
				}
				tiqian() {
					if (this.chaoxiang == 'y') return this.tiyou();
					if (this.chaoxiang == 'z') return this.tizuo();
				}
				tihou() {
					if (this.chaoxiang == 'y') return this.tizuo();
					if (this.chaoxiang == 'z') return this.tiyou();
				}
				wqqian() {
					if (this.chaoxiang == 'y') return this.tiqian()+110;
					if (this.chaoxiang == 'z') return this.tizuo()-110;
				}
				wqhou() {
					if (this.chaoxiang == 'y') return this.tiqian()-10;;
					if (this.chaoxiang == 'z') return this.tizuo()+10;
				}
				gongjidonghua() {
					let s= this;
					s.gongjici = true;
					let a = 0;
					let zhen = [0.5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.5,0]
					let f = function () {
						s.cix= zhen[a];
						a++;
					}
					let si = setInterval(function () {
						f()
						if (a==zhen.length) {
							s.gongjici = false;
							clearInterval(si);
						}
					},1000/30)
				}
				tandonghua() {
					var s= this;
					let a = 0;
					var tans = [
						[0,5,0,5],
						[0,10,0,10],
						[0,15,0,15],
						[0,20,0,20],
						[0,15,0,15],
						[0,10,0,10],
						[0,5,0,5],
						[-5,0,-5,0],
						[-10,0,-10,0],
						[-15,0,-15,0],
						[-10,0,-10,0],
						[-5,0,-5,0],
						[5,0,5,0],
						[10,0,10,0],
						[15,0,15,0],
						[10,0,10,0],
						[5,0,5,0]						
					]
					var f = function () {
						s.tx= tans[a][0];
						s.ty= tans[a][1];
						s.tx1= tans[a][2];
						s.ty1= tans[a][3];
						a++;
					}
					let si = setInterval(function () {
						f(a);
						if (a==tans.length) {
							s.tx = 0;
							s.ty = 0;
							s.tx1 = 0;
							s.ty1 = 0;
							clearInterval(si);
						}
					},1000/40)
				}
				//移动碰撞判定
				//点判定
				//		 . . .
				//		 . . .
				yidongpanding() {
					let pengdao;
					let s = this;
					let dianzu = [
						[s.tizuo(),s.tidi()],
						[s.tiyou(),s.tidi()],
						[(s.tizuo()+s.tiyou())/2 ,s.tidi()],
						[s.tizuo(),s.tidinei()],
						[s.tiyou(),s.tidinei()],
						[(s.tizuo()+s.tiyou())/2 ,s.tidinei()]
					] 
					huajihe.forEach(i=>{
						dianzu.forEach(x=>{
							if (i.bianhao != s.bianhao) {								
								if (x[0] > i.tizuo()&& x[0] < i.tiyou()&&
								x[1] < i.tidi()&&x[1] > i.tidinei()) pengdao = true;
							}
						})
					})
					return pengdao
				}
				//移动和攻击
				ydh() {
					var s = this;
					if (s.huozhe) {
						//攻击函数
						let gongji = function () {
							if (s.cisuo) {								
								//攻击判定
								if (((s.tidi() <= nwo.tidi()&&s.tidi() >= nwo.tidinei())||(s.tidinei() <= nwo.tidi()&&s.tidinei() >= nwo.tidinei()))&&
								((s.wqqian() >= nwo.tizuo() && s.wqhou() <= nwo.tizuo())||(s.wqqian() <= nwo.tiyou() && s.wqhou() >= nwo.tiyou()))) {
										s.cisuo = false;
										setTimeout(()=>{
											if (s.huozhe) {
												s.gongjidonghua();
												setTimeout(()=>{
													if (((s.tidi() <= nwo.tidi()&&s.tidi() >= nwo.tidinei())||(s.tidinei() <= nwo.tidi()&&s.tidinei() >= nwo.tidinei()))&&
													((s.wqqian() >= nwo.tizuo() && s.wqhou() <= nwo.tizuo())||(s.wqqian() <= nwo.tiyou() && s.wqhou() >= nwo.tiyou()))) {
														nwo.beigongji(s.gongjili);
													}
												},100)
												s.cisuo=true;
											}
										},1500)
								}
							}
						}
						gongji();
						//移动
						var m = 12 ;//m要比静止区域小
						if (s.suo) {
							s.suo = false;
							setTimeout(()=>s.suo=true,600)
							//跟踪方向判定
							//15 静止区域
							if ((s.tizuo()<(nwo.tizuo()-(s.tiyou()-s.tizuo())-15))||
							((s.tizuo()+s.tiyou())/2>=(nwo.tizuo()+nwo.tiyou())/2&&s.tizuo()<nwo.tiyou())
							) {
								s.fangxiangy = 'y';
								s.chaoxiang = 'y';
								if ((s.tizuo()+s.tiyou())/2>=(nwo.tizuo()+nwo.tiyou())/2&&
								s.tizuo()<nwo.tiyou()) s.chaoxiang = 'z';
								s.fangxiangz = '';
							}else {s.fangxiangy = '';
							}							
							if (s.tizuo()>nwo.tiyou()+15||
							((s.tizuo()+s.tiyou())/2<(nwo.tizuo()+nwo.tiyou())/2&&s.tizuo()>(nwo.tizuo()-(s.tiyou()-s.tizuo())))
							) {
								s.fangxiangz = 'z';
								s.chaoxiang = 'z';
								if ((s.tizuo()+s.tiyou())/2<(nwo.tizuo()+nwo.tiyou())/2&&
								s.tizuo()>(nwo.tizuo()-(s.tiyou()-s.tizuo()))) s.chaoxiang = 'y';
								s.fangxiangy = '';
							}else {s.fangxiangz = '';
							}
							if (s.tidi()>nwo.tidi()-20+15) {
								s.fangxiangs = 's';
								s.fangxiangx = '';
							}else {s.fangxiangs = '';
							}
							if (s.tidi()<nwo.tidi()-20) {
								s.fangxiangx = 'x';
								s.fangxiangs = '';
							}else {s.fangxiangx = '';
							}
							//移动
							if (s.fangxiangy == 'y') {
								s.x += m;
								if (s.yidongpanding()) {
									s.x -= m;
									s.fangxiangy = '';
								}else{
									s.tandonghua();
								}
							}
							if (s.fangxiangz == 'z') {
								s.x -= m;
								if (s.yidongpanding()) {
									s.x += m;
									s.fangxiangz = '';
								}else{
									s.tandonghua();
								}
							}					
							if (s.fangxiangs == 's') {
								s.y -= m;
								if (s.yidongpanding()) {
									s.y += m;
									s.fangxiangs = '';
								}else{
									s.tandonghua();
								}
							}					
							if (s.fangxiangx == 'x') {
								s.y += m;
								if (s.yidongpanding()) {
									s.y -= m;
									s.fangxiangx = '';
								}else{
									s.tandonghua();
								}
							}						
						}
					}
				}
				//被攻击数字文本
				huawenben(a) {
					let s = this;
					let i = 0;
					function hua(a,b) {
						return function () {
							ctx.save();
							ctx.beginPath();
							ctx.strokeStyle = '#5f5f5f'
							ctx.fillStyle = '#de3226'
							ctx.font="40px Arial";
							ctx.strokeText(`-${Math.round(a)}`,s.x+b,s.y-20-b);;
							ctx.fillText(`-${Math.round(a)}`,s.x+b,s.y-20-b);
							ctx.restore();
						}
					}
					let huas = setInterval(function() {
						s.wenben.push(hua(a,i));
						i += 1.3;
						if (i>40) {
							clearInterval(huas)
						}
					},1000/60)
				}
				//被攻击函数
				beigongji(a) {
					let s = this;
					if (s.huozhe) {
						s.tandonghua();
						if (s.xueliang>0) {
							s.xueliang -= a;
							shengyin()
							s.huawenben(a)
							s.xueliang<0?s.xueliang=0:true;
							s.xuetiao = s.xueliang*s.zongxuetiao/s.zongxueliang;
						}
						if (s.xueliang==0) {
							s.huozhe = false;
							let siwangdonghua = new Promise(function(resolve,reject) {
								let si = setInterval(function () {
									s.ty += 10;
									s.ty1 += 10;
									if (s.ty>60) {
										clearInterval(si);
										resolve()
									}
								},1000/30)
							})
							siwangdonghua.then(()=>{
								s.shiqu = true;
							})
						}
					}
				}
				hua() {
					var s = this;
					//血条
					ctx.save();
					ctx.beginPath();
					ctx.moveTo(s.x-40,s.y-100);
					ctx.lineTo(s.x+40,s.y-100)
					ctx.strokeStyle = '#951a2c';
					ctx.lineWidth = 15;
					ctx.lineCap = "square";
					ctx.stroke()
					ctx.beginPath();
					ctx.moveTo(s.x-40,s.y-100);
					ctx.lineTo(s.x-40+s.xuetiao,s.y-100)
					ctx.strokeStyle = '#ea8b8f';
					ctx.lineWidth = 10;
					ctx.lineCap = "butt";
					ctx.stroke()
					ctx.beginPath();
					ctx.fillStyle = '#ffffff';
					ctx.textAlign = 'center';
					ctx.font = '15px 楷体';
					ctx.fillText(`${Math.round(s.xueliang)}`,s.x,s.y-95)
					ctx.restore();
					var h = function (ctx,s) {
						ctx.save();
						//底部
						ctx.save();
						ctx.beginPath();
						ctx.moveTo(s.x-65,s.y);
						ctx.bezierCurveTo(s.x-65,s.y-35,s.x+65,s.y-35,s.x+65,s.y);
						ctx.moveTo(s.x-65,s.y);
						ctx.bezierCurveTo(s.x-65,s.y+30,s.x+65,s.y+30,s.x+65,s.y);
						ctx.fillStyle = "#d3b99c";
						ctx.fill();
						ctx.restore();
						//身体
						ctx.beginPath();
						ctx.moveTo(s.x-70,s.y);
						ctx.bezierCurveTo(s.x-70+s.tx,s.y-120+s.ty,s.x+70+s.tx1,
						s.y-120+s.ty1,s.x+70,s.y);
						ctx.moveTo(s.x-70,s.y);
						ctx.bezierCurveTo(s.x-70,s.y+40,s.x+70,s.y+40,s.x+70,s.y);
						ctx.strokeStyle = "#b0ab93";
						var grad = ctx.createRadialGradient(s.x+70,s.y-10,0,s.x+70,s.y-10,50)
						grad.addColorStop(0,"#7d7961");
						grad.addColorStop(0.5,"#b1a077");
						grad.addColorStop(1,"#e7cfa0");
						ctx.fillStyle = grad;
						ctx.globalAlpha = 0.7;
						ctx.lineWidth = 2;
						ctx.fill();
						ctx.stroke();
						//眼睛
						ctx.save();
						ctx.beginPath();
						ctx.arc(s.x-45+s.tx, s.y-57+s.ty, 5, 0, Math.PI * 2, true);
						ctx.arc(s.x-30+s.tx, s.y-55+s.ty, 6, 0, Math.PI * 2, true);
						ctx.fillStyle = '#2c3d2e';
						ctx.fill();
						ctx.restore();
						//高光
						ctx.save();
						ctx.globalAlpha = 1;
						ctx.beginPath();
						ctx.translate(s.x+5+s.tx,s.y-70+s.ty);
						ctx.scale(1,0.5);
						ctx.arc(20, 20, 20, 0, Math.PI * 2, true);
						ctx.fillStyle = '#ffffff';
						ctx.fill();
						ctx.restore();
						//攻击刺
						if (s.gongjici) {
							ctx.save();
							ctx.beginPath();
							ctx.moveTo(s.x-50,s.y-46);
							ctx.lineTo(s.x-50-130*s.cix,s.y-51);
							ctx.lineTo(s.x-55,s.y-21);
							ctx.strokeStyle = '#b0ab93'
							ctx.stroke();
							ctx.fillStyle = '#e7cfa0';
							ctx.fill();
							ctx.restore();
						}
						
						ctx.restore();
					}					
					if (s.chaoxiang == 'z' || s.fangxiangy == 'z') {
						h(ctx,s);
					}
					if (s.chaoxiang == 'y' || s.fangxiangz == 'y') {
						ctx.save();
						ctx.translate(canvas.width,0);
						ctx.scale(-1,1);
						let ss = Object.assign({},s);
						//this.x必须是怪中线
						ss.x = canvas.width-ss.x;
						h(ctx,ss);
						ctx.restore()
					}
					s.wenben.forEach(x=>x());
					s.wenben = [];
					//画掉落
					if (s.shiqu) {
						ctx.save()
						let wt = new Path2D(`M${s.x} ${s.y-50} l-30 15 h25 z`)
						let wt1 = new Path2D(`M${s.x} ${s.y-50} l30 15 h-35 z`)
						let wt2 = new Path2D(`M${s.x} ${s.y-20} l-30 -15 h25 z`)
						let wt3 = new Path2D(`M${s.x} ${s.y-20} l30 -15 h-35 z`)
						ctx.strokeStyle = '#c2d3d8'
						ctx.fillStyle = '#bdbdbd';
						ctx.fill(wt)
						ctx.stroke(wt);
						ctx.fillStyle = '#f7f7f7';
						ctx.fill(wt1)
						ctx.stroke(wt1);
						ctx.fillStyle = '#505050';
						ctx.fill(wt2)
						ctx.stroke(wt2);
						ctx.fillStyle = '#919191';
						ctx.fill(wt3)
						ctx.stroke(wt3);
						ctx.restore()
					}
				}			
			}
			class daslm {
				constructor(x,y,b) {
					this.leixing = 'guai';
					this.bianhao = b;
					this.huozhe = true;
					this.x = x;
					this.y = y;
					this.tx = 0;
					this.ty = 0;
					this.tx1 = 0;
					this.ty1 = 0;
					this.cix = 0;
					this.gongjici = false;
					this.cisuo = true;
					this.suo = true;
					this.chaoxiang = 'z';
					this.fangxiangy = "";
					this.fangxiangz = "";
					this.fangxiangs = "";
					this.fangxiangx = "";
					this.zongxueliang = guaitisheng(400);
					this.zongxuetiao = 80;
					this.xueliang = guaitisheng(400);
					this.xuetiao =80;
					this.gongjili = guaitisheng(20);
					this.wenben = [];
					this.shiqu = false;
				}
				//位置
				tiding() {
					return this.y-200
				}
				tidi() {
					return this.y+30;
				}
				tidinei() {
					return this.y-20;
				}
				tizuo() {
					return this.x-70;
				}
				tiyou() {
					return this.x+70;
				}
				tiqian() {
					if (this.chaoxiang == 'y') return this.tiyou();
					if (this.chaoxiang == 'z') return this.tizuo();
				}
				tihou() {
					if (this.chaoxiang == 'y') return this.tizuo();
					if (this.chaoxiang == 'z') return this.tiyou();
				}
				wqqian() {
					if (this.chaoxiang == 'y') return this.tiqian()+110;
					if (this.chaoxiang == 'z') return this.tizuo()-110;
				}
				wqhou() {
					if (this.chaoxiang == 'y') return this.tiqian()-10;;
					if (this.chaoxiang == 'z') return this.tizuo()+10;
				}
				gongjidonghua() {
					let s= this;
					s.gongjici = true;
					let a = 0;
					let zhen = [0.5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0.5,0]
					let f = function () {
						s.cix= zhen[a];
						a++;
					}
					let si = setInterval(function () {
						f()
						if (a==zhen.length) {
							s.gongjici = false;
							clearInterval(si);
						}
					},1000/30)
				}
				tandonghua() {
					var s= this;
					let a = 0;
					var tans = [
						[0,5,0,5],
						[0,10,0,10],
						[0,15,0,15],
						[0,20,0,20],
						[0,15,0,15],
						[0,10,0,10],
						[0,5,0,5],
						[-5,0,-5,0],
						[-10,0,-10,0],
						[-15,0,-15,0],
						[-10,0,-10,0],
						[-5,0,-5,0],
						[5,0,5,0],
						[10,0,10,0],
						[15,0,15,0],
						[10,0,10,0],
						[5,0,5,0]						
					]
					var f = function () {
						s.tx= tans[a][0];
						s.ty= tans[a][1];
						s.tx1= tans[a][2];
						s.ty1= tans[a][3];
						a++;
					}
					let si = setInterval(function () {
						f(a);
						if (a==tans.length) {
							s.tx = 0;
							s.ty = 0;
							s.tx1 = 0;
							s.ty1 = 0;
							clearInterval(si);
						}
					},1000/40)
				}
				//移动碰撞判定
				//点判定
				//		 . . .
				//		 . . .
				yidongpanding() {
					let pengdao;
					let s = this;
					let dianzu = [
						[s.tizuo(),s.tidi()],
						[s.tiyou(),s.tidi()],
						[(s.tizuo()+s.tiyou())/2 ,s.tidi()],
						[s.tizuo(),s.tidinei()],
						[s.tiyou(),s.tidinei()],
						[(s.tizuo()+s.tiyou())/2 ,s.tidinei()]
					] 
					huajihe.forEach(i=>{
						dianzu.forEach(x=>{
							if (i.bianhao != s.bianhao) {								
								if (x[0] > i.tizuo()&& x[0] < i.tiyou()&&
								x[1] < i.tidi()&&x[1] > i.tidinei()) pengdao = true;
							}
						})
					})
					return pengdao
				}
				//移动和攻击
				ydh() {
					var s = this;
					if (s.huozhe) {
						//攻击函数
						let gongji = function () {
							if (s.cisuo) {								
								//攻击判定
								if (((s.tidi() <= nwo.tidi()&&s.tidi() >= nwo.tidinei())||(s.tidinei() <= nwo.tidi()&&s.tidinei() >= nwo.tidinei()))&&
								((s.wqqian() >= nwo.tizuo() && s.wqhou() <= nwo.tizuo())||(s.wqqian() <= nwo.tiyou() && s.wqhou() >= nwo.tiyou()))) {
										s.cisuo = false;
										setTimeout(()=>{
											if (s.huozhe) {
												s.gongjidonghua();
												setTimeout(()=>{
													if (((s.tidi() <= nwo.tidi()&&s.tidi() >= nwo.tidinei())||(s.tidinei() <= nwo.tidi()&&s.tidinei() >= nwo.tidinei()))&&
													((s.wqqian() >= nwo.tizuo() && s.wqhou() <= nwo.tizuo())||(s.wqqian() <= nwo.tiyou() && s.wqhou() >= nwo.tiyou()))) {
														nwo.beigongji(s.gongjili);
													}
												},100)
												s.cisuo=true;
											}
										},1500)
								}
							}
						}
						gongji();
						//移动
						var m = 12 ;//m要比静止区域小
						if (s.suo) {
							s.suo = false;
							setTimeout(()=>s.suo=true,600)
							//跟踪方向判定
							//15 静止区域
							if ((s.tizuo()<(nwo.tizuo()-(s.tiyou()-s.tizuo())-15))||
							((s.tizuo()+s.tiyou())/2>=(nwo.tizuo()+nwo.tiyou())/2&&s.tizuo()<nwo.tiyou())
							) {
								s.fangxiangy = 'y';
								s.chaoxiang = 'y';
								if ((s.tizuo()+s.tiyou())/2>=(nwo.tizuo()+nwo.tiyou())/2&&
								s.tizuo()<nwo.tiyou()) s.chaoxiang = 'z';
								s.fangxiangz = '';
							}else {s.fangxiangy = '';
							}							
							if (s.tizuo()>nwo.tiyou()+15||
							((s.tizuo()+s.tiyou())/2<(nwo.tizuo()+nwo.tiyou())/2&&s.tizuo()>(nwo.tizuo()-(s.tiyou()-s.tizuo())))
							) {
								s.fangxiangz = 'z';
								s.chaoxiang = 'z';
								if ((s.tizuo()+s.tiyou())/2<(nwo.tizuo()+nwo.tiyou())/2&&
								s.tizuo()>(nwo.tizuo()-(s.tiyou()-s.tizuo()))) s.chaoxiang = 'y';
								s.fangxiangy = '';
							}else {s.fangxiangz = '';
							}
							if (s.tidi()>nwo.tidi()-20+15) {
								s.fangxiangs = 's';
								s.fangxiangx = '';
							}else {s.fangxiangs = '';
							}
							if (s.tidi()<nwo.tidi()-20) {
								s.fangxiangx = 'x';
								s.fangxiangs = '';
							}else {s.fangxiangx = '';
							}
							//移动
							if (s.fangxiangy == 'y') {
								s.x += m;
								if (s.yidongpanding()) {
									s.x -= m;
									s.fangxiangy = '';
								}else{
									s.tandonghua();
								}
							}
							if (s.fangxiangz == 'z') {
								s.x -= m;
								if (s.yidongpanding()) {
									s.x += m;
									s.fangxiangz = '';
								}else{
									s.tandonghua();
								}
							}					
							if (s.fangxiangs == 's') {
								s.y -= m;
								if (s.yidongpanding()) {
									s.y += m;
									s.fangxiangs = '';
								}else{
									s.tandonghua();
								}
							}					
							if (s.fangxiangx == 'x') {
								s.y += m;
								if (s.yidongpanding()) {
									s.y -= m;
									s.fangxiangx = '';
								}else{
									s.tandonghua();
								}
							}						
						}
					}
				}
				//被攻击数字文本
				huawenben(a) {
					let s = this;
					let i = 0;
					function hua(a,b) {
						return function () {
							ctx.save();
							ctx.beginPath();
							ctx.strokeStyle = '#5f5f5f'
							ctx.fillStyle = '#de3226'
							ctx.font="40px Arial";
							ctx.strokeText(`-${Math.round(a)}`,s.x+b,s.y-20-b);;
							ctx.fillText(`-${Math.round(a)}`,s.x+b,s.y-20-b);
							ctx.restore();
						}
					}
					let huas = setInterval(function() {
						s.wenben.push(hua(a,i));
						i += 1.3;
						if (i>40) {
							clearInterval(huas)
						}
					},1000/60)
				}
				//被攻击函数
				beigongji(a) {
					let s = this;
					if (s.huozhe) {
						s.tandonghua();
						if (s.xueliang>0) {
							s.xueliang -= a;
							shengyin()
							s.huawenben(a)
							s.xueliang<0?s.xueliang=0:true;
							s.xuetiao = s.xueliang*s.zongxuetiao/s.zongxueliang;
						}
						if (s.xueliang==0) {
							s.huozhe = false;
							let siwangdonghua = new Promise(function(resolve,reject) {
								let si = setInterval(function () {
									s.ty += 10;
									s.ty1 += 10;
									if (s.ty>60) {
										clearInterval(si);
										resolve()
									}
								},1000/30)
							})
							siwangdonghua.then(()=>{
								s.shiqu = true;
							})
						}
					}
				}
				hua() {
					var s = this;
					//血条
					ctx.save();
					ctx.beginPath();
					ctx.moveTo(s.x-40*2,s.y-100*2);
					ctx.lineTo(s.x+40*2,s.y-100*2)
					ctx.strokeStyle = '#951a2c';
					ctx.lineWidth = 15;
					ctx.lineCap = "square";
					ctx.stroke()
					ctx.beginPath();
					ctx.moveTo(s.x-40*2,s.y-100*2);
					ctx.lineTo(s.x-40*2+s.xuetiao*2,s.y-100*2)
					ctx.strokeStyle = '#ea8b8f';
					ctx.lineWidth = 10;
					ctx.lineCap = "butt";
					ctx.stroke()
					ctx.beginPath();
					ctx.fillStyle = '#ffffff';
					ctx.textAlign = 'center';
					ctx.font = '15px 楷体';
					ctx.fillText(`${Math.round(s.xueliang)}`,s.x,s.y-195)
					ctx.restore();
					var h = function (ctx,s) {
						ctx.save();
						//底部
						ctx.save();
						ctx.beginPath();
						ctx.moveTo(s.x-65*2,s.y);
						ctx.bezierCurveTo(s.x-65*2,s.y-35*2,s.x+65*2,s.y-35*2,s.x+65*2,s.y);
						ctx.moveTo(s.x-65*2,s.y);
						ctx.bezierCurveTo(s.x-65*2,s.y+30*2,s.x+65*2,s.y+30*2,s.x+65*2,s.y);
						ctx.fillStyle = "#c22315";
						ctx.fill();
						ctx.restore();
						//身体
						ctx.beginPath();
						ctx.moveTo(s.x-70*2,s.y);
						ctx.bezierCurveTo(s.x-70*2+s.tx,s.y-120*2+s.ty,s.x+70*2+s.tx1,
						s.y-120*2+s.ty1,s.x+70*2,s.y);
						ctx.moveTo(s.x-70*2,s.y);
						ctx.bezierCurveTo(s.x-70*2,s.y+40*2,s.x+70*2,s.y+40*2,s.x+70*2,s.y);
						ctx.strokeStyle = "#b0908b";
						var grad = ctx.createRadialGradient(s.x+70*2,s.y-10*2,0,s.x+70*2,s.y-10*2,50)
						grad.addColorStop(0,"#7d665f");
						grad.addColorStop(0.5,"#b17c75");
						grad.addColorStop(1,"#e7a4a0");
						ctx.fillStyle = grad;
						ctx.globalAlpha = 0.7;
						ctx.lineWidth = 2;
						ctx.fill();
						ctx.stroke();
						//眼睛
						ctx.save();
						ctx.beginPath();
						ctx.arc(s.x-45*2+s.tx, s.y-57*2+s.ty, 5*2, 0, Math.PI * 2, true);
						ctx.arc(s.x-30*2+s.tx, s.y-55*2+s.ty, 6*2, 0, Math.PI * 2, true);
						ctx.fillStyle = '#3d0b05';
						ctx.fill();
						ctx.restore();
						//高光
						ctx.save();
						ctx.globalAlpha = 1;
						ctx.beginPath();
						ctx.translate(s.x+5*2+s.tx,s.y-70*2+s.ty);
						ctx.scale(1,0.5);
						ctx.arc(20*2, 20*2, 20*2, 0, Math.PI * 2, true);
						ctx.fillStyle = '#ffffff';
						ctx.fill();
						ctx.restore();
						//攻击刺
						if (s.gongjici) {
							ctx.save();
							ctx.beginPath();
							ctx.moveTo(s.x-50*2,s.y-46*2);
							ctx.lineTo(s.x-50*2-130*2*s.cix,s.y-51*2);
							ctx.lineTo(s.x-55*2,s.y-21*2);
							ctx.strokeStyle = '#b0928e'
							ctx.stroke();
							ctx.fillStyle = '#e7a8a2';
							ctx.fill();
							ctx.restore();
						}
						
						ctx.restore();
					}					
					if (s.chaoxiang == 'z' || s.fangxiangy == 'z') {
						h(ctx,s);
					}
					if (s.chaoxiang == 'y' || s.fangxiangz == 'y') {
						ctx.save();
						ctx.translate(canvas.width,0);
						ctx.scale(-1,1);
						let ss = Object.assign({},s);
						//this.x必须是怪中线
						ss.x = canvas.width-ss.x;
						h(ctx,ss);
						ctx.restore()
					}
					s.wenben.forEach(x=>x());
					s.wenben = [];
					if (s.shiqu) {
						ctx.save()
						let wt = new Path2D(`M${s.x} ${s.y-50} l-30 15 h25 z`)
						let wt1 = new Path2D(`M${s.x} ${s.y-50} l30 15 h-35 z`)
						let wt2 = new Path2D(`M${s.x} ${s.y-20} l-30 -15 h25 z`)
						let wt3 = new Path2D(`M${s.x} ${s.y-20} l30 -15 h-35 z`)
						ctx.strokeStyle = '#c2d3d8'
						ctx.fillStyle = '#bdbdbd';
						ctx.fill(wt)
						ctx.stroke(wt);
						ctx.fillStyle = '#f7f7f7';
						ctx.fill(wt1)
						ctx.stroke(wt1);
						ctx.fillStyle = '#505050';
						ctx.fill(wt2)
						ctx.stroke(wt2);
						ctx.fillStyle = '#919191';
						ctx.fill(wt3)
						ctx.stroke(wt3);
						ctx.restore()
					}
				}			
			}
			//门
			class men {
				constructor(x,y,b) {
					this.leixing = 'men';
					this.bianhao = b
					this.jinru = true;
					this.x = x;
					this.y = y;
					this.suo = true;
				}
				//位置
				tiding() {
					return this.y-190;
				}
				tidi() {
					return this.y+70;
				}
				tidinei() {
					return this.y;
				}
				tizuo() {
					return this.x
				}
				tiyou() {
					return this.x+28;
				}
				hua() {
					var s = this;
					if (!s.jinru) {				
						ctx.save();
						ctx.beginPath();
						ctx.moveTo(s.x,s.y);
						ctx.lineTo(s.x,s.y-190);
						ctx.lineTo(s.x+28,s.y-160);
						ctx.lineTo(s.x+28,s.y+70);
						ctx.fillStyle = '#d0a4d4';
						ctx.lineWidth = 10;
						ctx.stroke()
						ctx.fill()
						ctx.beginPath();
						ctx.moveTo(s.x+20,s.y-50);
						ctx.lineTo(s.x+25,s.y-50);
						ctx.stroke()
						ctx.restore();
					}else {
						ctx.save();
						ctx.beginPath();
						ctx.moveTo(s.x,s.y);
						ctx.lineTo(s.x,s.y-190);
						ctx.lineTo(s.x+28,s.y-160);
						ctx.lineTo(s.x+28,s.y+70);
						ctx.lineWidth = 10;
						ctx.stroke()
						ctx.beginPath();
						ctx.fillStyle = '#d0a4d4';
						ctx.moveTo(s.x,s.y);
						ctx.lineTo(s.x,s.y-180);
						ctx.lineTo(s.x-100,s.y-180);
						ctx.lineTo(s.x-100,s.y);
						ctx.fill();
						ctx.restore();
					}
				}
				ydh(){}
			}
			//商店
			class shangdian {
				constructor(x,y,b) {
					this.leixing = 'shangdian';
					this.bianhao = b;
					this.x = x;
					this.y = y;
					this.shangpin = [{name:'回血药剂',zhenpin:false,jiage:1,leixing:'用品'},{name:'加攻击力',zhenpin:true,jiage:1,leixing:'用品'}]
				}
				//位置
				tiding() {
					return this.y-100;
				}
				tidi() {
					return this.y+100;
				}
				tidinei() {
					return this.y;
				}
				tizuo() {
					return this.x
				}
				tiyou() {
					return this.x+150;
				}
				hua() {
					var s = this;
					ctx.save();
					ctx.beginPath();
					ctx.moveTo(s.tizuo(),s.tidinei());
					ctx.lineTo(s.tizuo(),s.tidi());
					ctx.lineTo(s.tiyou(),s.tidi());
					ctx.lineTo(s.tiyou(),s.tidinei());
					ctx.closePath()
					ctx.fillStyle = '#d44b06';
					ctx.lineWidth = 1;
					ctx.fill()
					ctx.restore()
				}
				ydh(){}
			}
			//人实例
			var nwo = new wo();
			
			function huapaixu(a,b) {
				return (a.tidinei() - b.tidinei())
			}
			//根据y轴顺序渲染和移动判定
			function zhonghua() {
				huajihe.sort(huapaixu)
				huajihe.forEach(x=>{
					x.ydh();
					x.hua();
				})
			}

			function beijing() {
				ctx.save()
				ctx.beginPath()
				ctx.moveTo(-40,canvas.height)
				ctx.lineTo(50,300)
				ctx.lineTo(1200,300)
				ctx.lineTo(canvas.width+40,canvas.height)
				ctx.fillStyle = "#cde7cb";
				ctx.fill()
				ctx.stroke()
				ctx.beginPath()
				ctx.moveTo(50,300)
				ctx.lineTo(50,0)
				ctx.lineTo(1200,0)
				ctx.lineTo(1200,300)
				ctx.fillStyle = '#f0feff'
				ctx.stroke()
				ctx.fill()
				ctx.beginPath()
				ctx.stroke()
				ctx.restore()
			}
			function beijingta() {
				ctx.save()
				ctx.beginPath()
				ctx.moveTo(-40,canvas.height)
				ctx.lineTo(50,300)
				ctx.lineTo(1200,300)
				ctx.lineTo(canvas.width+40,canvas.height)
				ctx.fillStyle = "#cfcde7";
				ctx.fill()
				ctx.stroke()
				ctx.beginPath()
				ctx.moveTo(50,300)
				ctx.lineTo(50,0)
				ctx.lineTo(1200,0)
				ctx.lineTo(1200,300)
				ctx.fillStyle = '#ffe2e6'
				ctx.stroke()
				ctx.fill()
				ctx.stroke()
				ctx.beginPath()
				ctx.fillStyle = '#d52e0d'
				ctx.font = '100px 楷体';
				ctx.fillText(`第${taceng}层`,450,200)
				ctx.restore()
				
			}
			var ditu;
			//不同地图配置
			function jihepeizhi() {
				taceng = 0;
				zongshangdian = new shangdian(650,350,'shangdian')
				huajihe = [nwo,new men(1200,450,'fubenta'),zongshangdian];
				ditu = 'tu';
			}
			function jihepeizhita() {
				nwo.x = 100;
				nwo.y = 350;
				taceng++;
				if (taceng%10==0) huajihe = [nwo,new daslm(1000,500,'daslm'),new men(1200,450,'fubenta')];
				else huajihe = [nwo,new slm(900,300,'slm1'),new slm(900,500,'slm2'),new men(1200,450,'fubenta')];
				ditu = 'tuta'
			}
			jihepeizhi()
			//进门配置判定
			function menpanding() {
				let men
				huajihe.forEach(x=>{
					if (x.leixing == 'men') {
						x.jinru=true;
						men = x
					}
				})
				huajihe.forEach(x=>{
					if (x.leixing == 'guai') {
						if (x.huozhe) {
							huajihe.forEach(x=>{
								if (x.leixing == 'men') {
									x.jinru=false;
								}
							})
						}
					}
				})
				//配置
				if (men) {
					if (nwo.tiyou()>=men.tizuo()&&nwo.tiyou()<=men.tiyou()&&nwo.tidi()<=men.tidi()&&nwo.tidi()>=men.tidinei()) {
						if (men.bianhao == 'fubenta') {
							nwo.x -= 50;
							cundangh();
							jihepeizhita()
						}
					}
				}
			}
			//画不同地图
			function dituh() {
				function zhuditu() {
					ctx.clearRect(0,0,canvas.width,canvas.height)
					ctx.save()
					beijing()
					zhonghua();
					ctx.restore()
				}
				function dituta() {
					ctx.clearRect(0,0,canvas.width,canvas.height)
					ctx.save()
					beijingta()
					zhonghua();
					ctx.restore()
				}				
				if (ditu == 'tu') {
					return zhuditu
				}
				if (ditu == 'tuta') {
					return dituta
				}
			}
			function huamian() {
				if (nwo.huozhe) {
					dituh()();
				}else {
					ctx.fillStyle = '#f33302'
					ctx.font = '300px 仿宋';
					ctx.fillText('凉凉',300,400)
				}
			}
			function draw() {
				menpanding()
				huamian()
				jiemianh()
				cundangh();
				requestAnimationFrame(draw)
			}
			draw()
		</script>
	</body>
</html>
 